package org.ysh.vo;

import lombok.Data;

@Data
public class R<T> {

    private Integer code;

    private String msg;

    private T data;

    public R(String msg){
        this(200,msg,null);
    }

    public R(Integer code,String msg,T data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static R ok(String msg){
        return new R(msg);
    }

    public static <T> R ok(T data) {
        return new R<>(200, null, data);
    }

    public static R ok() {
        return new R(null);
    }

    public static R<String> fail(String message) {
        return new R<>(500, message, null);
    }
}
